home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Communications / General / DialScript / Examples / im4u.ds < prev    next >
Text File  |  1994-03-08  |  4KB  |  136 lines

  1.  
  2. -- UTexas CS Dept. "im4u" login script.                    vers. 3/8/94
  3.  
  4. -- DialScript script for use with U Texas CS Dept modem pool attached to
  5. -- host im4u.
  6.  
  7. -- You need to set the variable for your username, etc. in state init and
  8. -- fix up state FinishUp (optional).
  9.  
  10. script im4u
  11.  
  12.    state init
  13.  
  14.       display "Beginning UT CS im4u login script.\r";
  15.       set online on;
  16.  
  17.       -- Here are things you may need to customize 
  18.  
  19.       setvar USERNAME "newton\r";
  20.       input PASSWORD noecho;        -- You could use a setvar here.
  21.  
  22.       setvar PHONE "ATDT4718454\r";
  23.  
  24.       setvar ModemInitString "AT\r";
  25.       setvar Modem_Escape_String "+++";
  26.  
  27.       set speed 2400;  -- If you use a 1200 baud modem, change this and take
  28.                        -- a look at state GotIt below.
  29.  
  30.       send ModemInitString;
  31.       next "ModemReady";
  32.  
  33.    end; -- init
  34.  
  35.  
  36.    -- This state makes sure we have the (Hayes-type) modem's attention.
  37.  
  38.    state ModemReady
  39.       repeat 2
  40.          send "AT\r";
  41.          select
  42.             "OK": next "Dial";
  43.             timeout 3: display "ModemReady timeout!\r";
  44.          end;
  45.          end; -- repeat
  46.  
  47.          next "HangUp";  -- failed again, maybe hangup
  48.    end; -- ModemReady
  49.  
  50.  
  51.    -- The state hangs up a Hayes modem by sending +++, waiting for OK,
  52.    -- and then sending ATH.
  53.  
  54.    state HangUp
  55.       repeat 2
  56.          delay 1; send Modem_Escape_String;
  57.          select
  58.             "OK"      : send "ATH\r"; next "ModemReady";
  59.             timeout 3 : display "HangUp timeout!\r";
  60.          end;
  61.       end;
  62.       
  63.       send "\r"; send "ATH\r";
  64.       next "ModemReady";
  65.    end; -- HangUp
  66.  
  67.  
  68.    -- This state dials the phone number and awaits the CONNECT message.
  69.    -- The select causes a redial if the line is busy, the modem responds
  70.    -- with NO CARRIER, or the modem does not respond with 25 seconds.
  71.  
  72.    state Dial
  73.       send PHONE;     -- The system's phone number
  74.       select
  75.          "CONNECT"    : next "GotIt";
  76.          "BUSY"       : next "Dial";
  77.          "NO CARRIER" : next "Dial";
  78.          timeout 25   : display "Dial timeout!\r"; next ModemReady;
  79.       end; 
  80.    end; -- Dial
  81.  
  82.  
  83.    -- This state enters the username and the password in reponse to
  84.    -- the appropriate prompts.
  85.  
  86.    state GotIt
  87.  
  88.       -- im4u responds at 1200 even when you login at 2400.  A break
  89.       -- cycles it among 1200 and 2400.  If you use 2400, you defintely
  90.       -- need to send a break.  Hence the "send break" *before* the select.
  91.       -- If you use 1200, you can move the send break after the "end;" of
  92.       -- the select statement to avoid timeouts.  You do not need to.
  93.  
  94.       repeat 6
  95.          send break; -- Best location for 2400 bps modems.
  96.          select 
  97.             "login:"   : send USERNAME; next "DoPass";
  98.             timeout 3 : display "login timeout!\r";
  99.          end;
  100.          -- send break; -- is better here for 1200 bps modems.
  101.       end;
  102.  
  103.    end; -- GotIt
  104.  
  105.  
  106.    state DoPass  -- Send the password
  107.       select
  108.          "Password:" : send PASSWORD; send "\r"; -- Your password and return
  109.          timeout 45  : display "password timeout!\r"; next "HangUp";
  110.       end;
  111.  
  112.       next "FinishUp";
  113.    end; -- DoPass
  114.  
  115.  
  116.    -- This state is used to answer the terminal type prompt.  The nature
  117.    -- of this prompt depends on your .login file on UNIX.  You need to
  118.    -- to customize this state for your circumstances.  I enter return
  119.    -- to confirm that I will use a vt100 emulator and then switch to
  120.    -- the emulator I use (MacLayers) by means of the transfer.  "RunLayers"
  121.    -- is my settings file for MacLayers.  This script has to be in the
  122.    -- same folder as MacLayers and RunLayers in order for the transfer to
  123.    -- succeed.  The transfer quits DialScript and runs MacLayers with
  124.    -- settings file RunLayers (as though I had double clicked on RunLayers
  125.    -- from the finder).
  126.  
  127.    state FinishUp   -- You need to customize this.  What's here is weak.
  128.  
  129.       wait "(vt100)";                      -- Terminal type prompt
  130.       send "\r";                           -- Yes to vt100
  131.       -- transfer "MacLayers" "RunLayers";    -- Run real terminal emulator
  132.  
  133.    end;  -- FinishUp
  134.  
  135. end; -- cs
  136.